
<?php 
	include_once("web_header.php");
?>
<script type="text/javascript"  src="/include/ajaxfileupload.js"></script>


 
<div class="web_wrap">
    <div class="reg_content_wrap">
         <div  style="width:25%;float:left;">
        <?php 
          include_once("web_coach_dashmenu.php");
        ?>
         </div>
         <div class="dash_rightdiv">
                  <div class="subhead"> 
               <span class="glyphicon glyphicon-th-list"></span>  编辑教学信息
           </div>



 <table style="width:100%;  " id="courselist">
  <tr style="background-color:#f0936c;color:#ffffff">
      <td>课程名称</td><td>说明</td><td style="width:20%">价格(元)</td><td style="width:20%">操作</td>
  </tr>
 
  <?php if($c_course_list): ?>

  <?php foreach ($c_course_list as $course): ?>
  <tr>
        <td><?=$course->course_name?></td><td><?=$course->course_desc?></td><td><?=$course->price?></td>
        <td>
           <button cid="<?=$course->id?>"   type="button" class="editBtn btn btn-link btn-sm"> 修改</button>
           <button cid="<?=$course->id?>"  type="button" class="delBtn btn btn-link btn-sm"> 删除</button>
        </td>
  </tr>
 <?php endforeach; ?>
 <?php endif; ?>



</table>      
 
 <br>
<button id="createBtn" type="button" class="btn btn-link"> <span class="glyphicon glyphicon-plus-sign"></span> 添加教学</button>


<div id="createbox" style="display:none">
     <div id="regform" >

          <!-- step 1 -->
           <div id="step1" style=" position:relative; ">



                <div class="formgroup" style="height:100px; display:none">
                     <h3><span class="mustspan">*</span>项目</h3>
                     <div class="inputcontent" id="stypeselectdiv">
                      <span svar="1" selectstatus="unselected" class="stypeselector buttondiv">健身</span> 
                          <span svar="2" selectstatus="unselected" class="stypeselector buttondiv">羽毛球</span> 
                          <span svar="3" selectstatus="unselected" class="stypeselector buttondiv">网球</span> 
 
                      <span svar="4" selectstatus="unselected" class="stypeselector buttondiv">高尔夫</span> 
                      <span svar="5" selectstatus="unselected" class="stypeselector buttondiv">游泳</span> 
                      <br>
                      <span svar="6" selectstatus="unselected" class="stypeselector buttondiv">瑜伽</span> 
 
                      <span svar="7" selectstatus="unselected" class="stypeselector buttondiv">跑步</span> 
                      <span svar="0" id="showorthertypebut"  selectstatus="unselected" class="stypeselector buttondiv">其他</span> 
                      <br>
                       </div>
                </div>
 
 
                 <div class="formgroup" id="othertypediv" style="display:none">
                     <h3> 其他项目</h3>
                     <input type="input" value="" name="othertype" id="othertype" placeholder="如果以上没有列有">
                </div>



                 <div class="formgroup">
                     <h3> <span class="mustspan">*</span>教学名称</h3>
                     <input type="input" value="" name="course_name" id="course_name" placeholder="设置课程名称">
                </div>



                <div class="formgroup" style="height:120px;">
                    <h3>教学要点</h3>
                   <textarea name="course_desc" id="course_desc" placeholder="课程要点"></textarea>
                    <div class="clearbox"></div>
                </div>


                 <div class="formgroup">
                     <h3> <span class="mustspan">*</span>价格</h3>
                     <input type="input" value="" name="price" id="price" placeholder="设置每小时价格(单位:元)">
                </div>

                 <div class="formgroup">
                     <h3> &nbsp; </h3>
                    <button id="submitButton" type="" class="btn btn-primary">
                       <div id="submitButtonText">添加</div>
                    </button>
                   <button id="cancleBtn" type="button" class="btn btn-link">取消</button>
                </div>

                  <div class="blankbox"></div>

            </div>
 
  </div>        

 
      <div style="height:20px;">
         </div>

</div>


         </div>
         <div style="clear:both"></div>

     </div>
</div>
 

 


<script type="text/javascript">

   var userid = '';
   var phonenumber = '';
   var wx_openid = '';
   var stypevar = '';
   var othertypeval = '';

   $("#showorthertypebut").on('click',function(){
        $("#othertypediv").show();
   });

   $("#createBtn").on('click',function(){
        $("#createbox").slideDown();
   });

   $("#cancleBtn").on('click',function(){
        $("#createbox").slideUp();
   });



   $(".editBtn").on('click',function(){
      var cid = $(this).attr("cid");
      window.location.href="/index.php/coach/web_dashboard_courseinfo_edit?cid="+cid;
   });

   $(".delBtn").on('click',function(){
      var cid = $(this).attr("cid");
      layer.open({
          content: '确定要删除吗?',
          btn: ['确认','取消'],
          shadeClose: false,
          yes: function(){
              sendDel(cid);
              layer.closeAll();
          }, no: function(){
               layer.close();
          }
      });
   });


   $(".stypeselector").on('click',function(){
        var selectedvar = $(this).attr("svar");
        $(".stypeselector").removeClass("buttondiv_selected");
        $(".stypeselector").addClass("buttondiv");
        $(this).addClass("buttondiv_selected");
        $(this).removeClass("buttondiv");
        stypevar = selectedvar;
        if(stypevar!=0){
             $("#othertypediv").hide();
             $("#othertype").val("");
        }
   });

   $(".stypeselector").each(function(){
        var selectedvar = $(this).attr("svar");
        if( selectedvar == stypevar){
             $(this).addClass("buttondiv_selected");
        }
    });

   if(othertypeval!=''){
        $("#othertypediv").show();
   }



   
   $("#submitButton").on('click',function(){
         sendInfo_1();
   });

    function showlayer(showword){
      layer.open({
          content:showword,
          style: 'background-color:#09C1FF; color:#fff; border:none;',
          time: 2
      });
    }



   function sendDel(cid){

        $.ajax({
            url: '/index.php/coach/web_dashboard_courseinfo_del_handle',
            type: 'POST',
            data:{ cid:cid },
            dataType: 'json',
            error: function(){
                  alert('Error loading PHP document'); 
                  posting = false;
                 },
            success: function(result){

              if(result.result==1){
                  layer.open({
                            content: '删除完成!',
                            className: 'bluelayer',
                            time: 2
                  });
              window.location.reload();
              return;
            }
          }

        });

   }


    function sendInfo_1(){

      //获取所选取的
   
      var course_desc = $("#course_desc").val();
      var course_name = $("#course_name").val();
      var price = $("#price").val();
      var course_id = '0';
 
      layer.open({
          content: '正在注册',
          className: 'bluelayer'
      });

        $.ajax({
            url: '/index.php/coach/web_dashboard_courseinfo_handle',
            type: 'POST',
            data:{ course_id:course_id, course_name:course_name, course_desc:course_desc, price:price  },
            dataType: 'json',
            error: function(){
                  alert('Error loading PHP document'); 
                  posting = false;
                 },
            success: function(result){
 
                if(result.result==7){
                      layer.open({
                      content: '请重新登录',
                      className: 'bluelayer',
                      time: 2
                  });
                      return;
                 }

                if(result.result==9){
                      layer.open({
                      content: '请先完善基本资料',
                      className: 'bluelayer',
                      time: 2
                  });
                      return;
                 }


                if(result.result==1){
                       layer.open({
                                  content: '添加完成!',
                                  className: 'bluelayer',
                                  time: 2
                        });
                    window.location.reload();
                      return;
               //send sms

                }else{
                      layer.open({
                            content: '请填写完整',
                            className: 'bluelayer',
                            time: 2
                        });
                      return;

                }
                posting = false;
            }
        });

    }

  

</script>




<?php 
	include_once("web_footer.php");
?>
